Skip to main content

Variables

Variable provide a place to store data that might be used in several places in a report. Variables can be used as parameters in a report (to narrow down the data being returned) and can be updated by a user in the user interface meaning they can be used to make a report interactive.

Creating a variable

Variables are created by right-clicking in the dictionary area and selecting 'New Variable'. Give your variable a name (this cannot include spaces or special characters) and an alias. The alias is what a user would see and can include spaces etc. so if this variable is going to be used for end-user interactivity, make it something meaninful. The variable type should correspond to the type of data you are using it for, generally speaking a 'string' for general text, a 'double' for numbers (offers the greatest precision) and a 'datetime' for dates and times should be used.

tip

If you are using the variable as a parameter on a query then it's best to use the same type as the underlying field on the database. You can check this by editing the table in the dictionary. The columns and their data types are shown at the bottom of the edit screen.

Variables by default are values, but they can also be a range or a list, either of which may be useful when using the variable as a parameter. This selection is available in the dropdown control next to the main variable type selection. The other option here is 'Nullable Value', which means it can contain a 'null' value (meaning 'having no value'). In some circumstances its useful to be able to differentiate this from an empty string.

The initial or default value of the variable can be set by a static value or an expression. Using an expression means the initial value can be dynamic, for example it could be held in a database that is viewable via a data source. To do this select 'Init by' instead of 'Expression' and then construct your expression. Use the pencil icon next to the expression fields to open up the expression window which then allows you to drag fields from the dictionary to this window.

If the variable is to be used as a parameter that users can interact with, click the 'Request from User' option which will open up some additional fields. 'Allow User Values' allows the user to enter values rather than being restricted to a predefined list. Whether or not this is selected, dropdown lists can still be configured by selecting a 'Data Source' of either 'Items' (a list of items you can determine) or 'Data Columns' which allows you to draw the data from the selected 'Keys' (the data source and field that contains the items you want to present in the dropdown).

 alt image

System Variables

System variables are listed separately in the dictionary. These are predefined values that can be dragged and dropped into reports and expressions. They allow you to include things like page numbers, current date and time and other useful data. These cannot be added to and are read-only.